package com.kamistoat.meimeimall.meimeimallproduct.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;

import com.kamistoat.meimeimall.common.utils.BaseEntity;
import com.kamistoat.meimeimall.common.valid.BrandAddGroup;
import com.kamistoat.meimeimall.common.valid.BrandSTUpdateGroup;
import com.kamistoat.meimeimall.common.valid.IntValueList;
import com.kamistoat.meimeimall.common.valid.BrandWholeUpdateGroup;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.URL;

import javax.validation.constraints.*;

/**
 * 品牌
 *
 * @author kamistoat
 * @email linjianshanke@163.com
 * @date 2021-09-12 14:28:44
 */
@EqualsAndHashCode(callSuper = true)
@Data
@TableName("pms_brand")
public class BrandEntity extends BaseEntity implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 品牌id
     * 在新增的时候，必须为空，因为自增
     * 而在修改的时候，必须不为空
     */
    @NotNull(message = "修改时必须指定品牌ID", groups = {BrandWholeUpdateGroup.class, BrandSTUpdateGroup.class})
    @Null(message = "新增时不能指定品牌ID", groups = {BrandAddGroup.class})
    @TableId
    private Long brandId;
    /**
     * 品牌名
     */
    @NotBlank(message = "品牌名应至少包含一个非空格字符", groups = {BrandWholeUpdateGroup.class, BrandAddGroup.class})
    @Null(message = "此操作下不允许修改品牌名", groups = {BrandSTUpdateGroup.class})
    private String name;
    /**
     * 品牌logo地址
     */
    @NotBlank(message = "logo地址不得为空", groups = {BrandWholeUpdateGroup.class, BrandAddGroup.class})
    @URL(message = "logo地址必须是合法的URL", groups = {BrandWholeUpdateGroup.class, BrandAddGroup.class})
    @Null(message = "此操作下不允许修改logo地址", groups = {BrandSTUpdateGroup.class})
    private String logo;
    /**
     * 介绍
     */
    @NotBlank(message = "品牌描述应至少包含一个非空格字符", groups = {BrandWholeUpdateGroup.class, BrandAddGroup.class})
    @Null(message = "此操作下不允许修改商品描述", groups = {BrandSTUpdateGroup.class})
    private String descript;
    /**
     * 显示状态[0-不显示；1-显示]
     */
    @IntValueList(vals = {0, 1}, message = "显示状态的值只能是0与1", groups = {BrandWholeUpdateGroup.class, BrandAddGroup.class, BrandSTUpdateGroup.class})
    private Integer showStatus;
    /**
     * 检索首字母
     */
    @NotBlank(message = "检索首字母不得为空", groups = {BrandWholeUpdateGroup.class, BrandAddGroup.class})
    @Pattern(regexp = "^[a-zA-Z]$", message = "检索首字母必须是英文字符", groups = {BrandWholeUpdateGroup.class, BrandAddGroup.class})
    @Null(message = "此操作下不允许修改检索首字母", groups = {BrandSTUpdateGroup.class})
    private String firstLetter;
    /**
     * 排序
     */
    @NotNull(message = "排序值不得为空", groups = {BrandWholeUpdateGroup.class, BrandAddGroup.class})
    @Min(value = 0, message = "排序值必须是大于等于零的整数", groups = {BrandWholeUpdateGroup.class, BrandAddGroup.class})
    @Null(message = "此操作下不允许修改排序值", groups = {BrandSTUpdateGroup.class})
    private Integer sort;

}
